from django.db import models


# Create your models here.

class Car(models.Model):
    name = models.CharField(max_length=50, blank=False, verbose_name='名称')
    img = models.CharField(max_length=255, blank=True, null=True, verbose_name='图片')
    desc = models.CharField(max_length=255, blank=True, null=True, verbose_name='描述')
    price = models.CharField(max_length=50, blank=False, verbose_name='价格')
    num = models.IntegerField(blank=False, verbose_name='库存')
    parent = models.ForeignKey('self', on_delete=models.CASCADE, blank=True, null=True, verbose_name='上级', related_name='son')
    user = models.ForeignKey('user.User', on_delete=models.CASCADE, blank=True, null=True, verbose_name='用户')

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'car'
